package icantalk;

import exception.VoipAlreadyActivatedException;
import icantalk.voip.VoipHandler;

public class VoipChatHandler {
	
	private VoipHandler m_voip = new VoipHandler();
	private ChatDialog m_userChatDialog = null;
	
	public VoipChatHandler()
	{
		
		
	}
	
	public void connectTo(String ip, ChatDialog userChatDialog) throws VoipAlreadyActivatedException
	{
		
		if ( !m_voip.isActive() )
		{
			m_userChatDialog = userChatDialog;
			
			m_voip.ConnectTo(ip);
			
			m_userChatDialog.setCallStatus(true);
		}
		else
		{
			throw new VoipAlreadyActivatedException();
		}
	}
	
	public void disconnect()
	{
		if ( m_voip.isActive() ) 
		{
			m_voip.hangup();
			m_userChatDialog.setCallStatus(false);
			
		}
	}
	
	public boolean isActiveStatus()
	{
		return ( m_voip.isActive() );
	}
	
}
